package com.cskaoyan._12io._01bytestream._02fileinputstream;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author Macro_Ray
 * @since 2024/3/23 15:03
 */
public class FileCopyDemo2 {
    public static void main(String[] args) throws IOException {
        // 拷贝 basketball1.mp4

        // 获取时间
        long start = System.currentTimeMillis();

        // 1.创建对象
        FileInputStream fis = new FileInputStream("basketball1.mp4");
        FileOutputStream fos = new FileOutputStream("Day17_Code/copy2.mp4");

        // 2.读写数据
        int len;
        byte[] bytes = new byte[1024*1024*5];
        while((len = fis.read(bytes))!=-1){
            fos.write(bytes,0,len);
        }

        // 3.释放资源
        fos.close();
        fis.close();

        // 计算耗时
        long end =System.currentTimeMillis();
        System.out.println(end-start);
    }
}
